<?php
require_once('../kelas/fungsi.php');
require_once('../kelas/record.php');
require_once('../kelas/useradmin.php');
?>

<link rel="stylesheet" type="text/css" href="<?php echo BASEURL.'css/isi.css' ?>">
<?php
echo $objFungsi->buatJudul('Login',110);
?>
<form method="POST" name="formLoginAdmin">
	<table style="margin:auto">
		<tr>
			<td>Username</td>
			<td><input name="username" /></td>
		</tr>
		<tr>
			<td>Password</td>
			<td><input name="password" type="password"/></td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="submit" value="Login" />
				<input type="reset" value="Reset" />

			</td>
		</tr>
	</table>
</form>
<script type="text/javascript">
$(document).ready(function(){
	var frmLogin = $(document).find('form[name="formLoginAdmin"]');
	frmLogin.submit(function(e){
		$.ajax({
			url:baseUrl +"proses/administrasi.php?on=login",
			data:frmLogin.serialize(),
			dataType:'JSON',
			type:'POST',
			success:function(res){
				console.log(res);
				if(res.success==true){
//					alert('kamu suksess');
					document.location= document.URL;
				}
				else{
					typeof(res);
					alert(res.error_msg);
				}
			},
			error:function(ree){
				alert('Login gagal, server terputus. Silahkan Coba Lagi');
			}

		});
		e.preventDefault();
	});
});
</script>